<?php
/**
 * houses class.
**/
class Houses extends EMongoDocument {
  // public $hId;
  public $uid;
  public $hsid;
  public $rooms;

  public function getCollectionName() {
    return 'Houses';
  }
  
  /**
   * This method have to be defined in every model, like with normal CActiveRecord
   */
  public static function model($className = __CLASS__) {
    return parent :: model($className);
  }
  
  
      // Add EEmbeddedArraysBehavior
    public function behaviors()
    {
        return array(
            'embeddedArrays' => array(
                'class'=>'ext.YiiMongoDbSuite.extra.EEmbeddedArraysBehavior',
                'arrayPropertyName'=>'rooms',       // name of property, that will be used as an array
                'arrayDocClassName'=>'Rooms'    // class name of embedded documents in array
            ),
        );
    }
  
  // /**
     // * This method should return simple array that will define field names for embedded
     // * documents, and class to use for them
     // */ 
    // public function behaviors()
    // {
// 
    // return array(
            // 'embeddedArrays' => array(
                // 'class'=>'ext.YiiMongoDbSuite.extra.EEmbeddedArraysBehavior',
                // 'arrayPropertyName'=>'goods',       // name of property, that will be used as an array
                // 'arrayDocClassName'=>'Goods'    // class name of embedded documents in array
            // ),
        // );
    // }
    
    // // within model class
  // public function embeddedDocuments()
  // {
      // return array(
          // 'goods' => 'Goods',
          // // 'some_other_field_name' => 'AnyEMongoEmbeddedDocumentChildClass',
      // );
  // }
  public static function findById($id){
	$id = new MongoId ( $id );
    return self::model()->findByAttributes(array('_id'=>$id));
	
} 
  public static function findByHid($hid) {
    return self :: model()->findByAttributes(array ('_id' => $hid));
  }
  
  public static function findAllByUid($uid) {
    return self :: model()->findAllByAttributes(array ('uid' => $uid));
  }
}
